package im.agents.users;

import im.domain.SLA;
import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

public class HandleViolations extends CyclicBehaviour {

	private SLA sla;
	public HandleViolations(Agent a, SLA sla){
		super(a);
		this.sla=sla;
	}
	@Override
	public void action() {
		ACLMessage msg = myAgent.receive(MessageTemplate.and(
				MessageTemplate.MatchContent("violazione"),
				MessageTemplate.MatchPerformative(ACLMessage.INFORM)));
		if(msg!=null){
			
				System.out.println(myAgent.getLocalName()
						+ " - Segnalata violazione SLA: "+sla.toString());
			
		}else{
			block();
		}
	}

}
